#include "RectangleRenderable.h"

namespace coolpool
{
	RectangleRenderable::RectangleRenderable(const math_tools::Vector3D & v1, const math_tools::Vector3D & v2, const math_tools::Vector3D & v3, const math_tools::Vector3D & v4, GLuint texture)
	{
		v1_ = v1;
		v2_ = v2;
		v3_ = v3;
		v4_ = v4;
		texture_ = texture;
	}

	RectangleRenderable::~RectangleRenderable()
	{

	}

	void RectangleRenderable::render() const
	{
		glColor3d(1.0, 1.0, 1.0);
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, texture_);

		glBegin(GL_QUADS);
		glTexCoord2f(1.0f, 1.0f);
		glVertex3d(v3_.getX(), v3_.getY(), v3_.getZ());
		glTexCoord2f(1.0f, 0.0f);
		glVertex3d(v2_.getX(), v2_.getY(), v2_.getZ());
		glTexCoord2f(0.0f, 0.0f);
		glVertex3d(v1_.getX(), v1_.getY(), v1_.getZ());
		glTexCoord2f(0.0f, 1.0f);
		glVertex3d(v4_.getX(), v4_.getY(), v4_.getZ());
		glEnd();
	}
}
